package org.elsfs.cloud.common.mybatis.ext.sql.support.delete;


import lombok.RequiredArgsConstructor;
import org.elsfs.cloud.common.mybatis.ext.sql.SqlFragment;

import java.util.Collection;
import java.util.stream.Collectors;

/**
 * 聚合删除项
 *

 */
@RequiredArgsConstructor
public class CompositeDeleteItem implements DeleteItem {

    /**
     * 删除项集合
     */
    private final Collection<DeleteItem> deleteItems;

    /**
     * 构建SQL片段
     *
     * @return SQL片段
     */
    @Override
    public String buildSqlFragment() {
        return this.deleteItems.stream()
            .map(SqlFragment::buildSqlFragment)
            .collect(Collectors.joining(", "));
    }
}
